<?php
/**
 * Created by PhpStorm.
 * User: dungnt13
 * Date: 11/28/14
 * Time: 4:38 PM
 */

namespace Frontend;

use AuthorizedController,
    Comment,
    Sentry,
    Input,
    Jinput,
    Validator,
    View,
    Exception,
    Redirect;


class CommentsController extends AuthorizedController
{
    public function postAdd()
    {
        $content = Jinput::get('content');
        $id = Jinput::get('id');
        $parent_id = Jinput::get('parentid', 0);
        $type = Jinput::get('type');
        $comment = new Comment();
        $comment->content = $content;
        $comment->parent_id = $parent_id;
        if ($type == 'lesson')
            $comment->lesson_id = $id;
        else if ($type == 'video')
            $comment->video_id = $id;
        else if ($type == 'lyric')
            $comment->lyric_id = $id;
        try {
            $comment->save();
            return true;
        } catch (Exception $ex) {
            return false;
        }
    }

    public function loadComment()
    {

    }

} 